jQuery(function($){
    
   	var arcList = [];
		var loadNum = 10;//每次点击加载的条数
    var lg_more1;var lg_morelist;var cNum;var cindex;var curl;var loaded;
		$(".lg_morelist").bind('click', function(){
			 curl ="../../"+ this.attributes['curl'].nodeValue.replace("index.htm", "index_json.json@v=0228");
			 cindex = this.attributes['cindex'].nodeValue
			 cNum=  this.attributes['cNum'].nodeValue
			 lg_more1 = $('.lg_more1').eq(cindex);
			 lg_morelist = $('.lg_morelist').eq(cindex);
			 loaded = parseInt(cNum) +loadNum;
  		$(".loadimg").eq(cindex).css("display","block");
    	$(this).ajaxError(function(){
  		//如果列表数据加载失败
  		$(".loadimg").eq(cindex).css("display","none");
    	lg_morelist.html('数据加载错误').unbind();//禁用按钮并提示出错
  	});
   	 $.get(curl, function(data){
  		$(".loadimg").eq(cindex).css("display","none");
		  var dataStr = data.replace(/,\s*?]/, ']');
		  //alert(dataStr);
		  try
		  {
			  arcList = $.parseJSON(dataStr);
			  arcList.pop();//删除最后一个空元素
		    var nextList = arcList.slice(cNum, loaded);
		    loadHtml(nextList);
			lg_morelist.attr("cNum",loaded);
			}
			catch(err)
			{
				arcList = null;
			  //alert(err);
	   		   lg_morelist.html('加载完成').unbind();//取消绑定事件
			}
		});
		});
  var loadHtml = function(listArr){
    var listHtml = '';
    //组织html代码
    for(var i=0; i<listArr.length; i++)
    {
	  listHtml +='  <div class="twolink"> <div>';
	  listHtml +='   <a href="'+listArr[i].httpdocumentpath+'">' + listArr[i].doclisttitle;
      listHtml +='   </a></div> </div>';
    }
    lg_more1.before(listHtml);
    //判断是否已加载全部
    if(loaded >= arcList.length)
    {
      lg_morelist.html('加载完成').unbind();//取消绑定事件
    }
  }
});